import fitz  # PyMuPDF
import sys
import os

def read_pdf(file_path):
    try:
        # 尝试使用PyMuPDF
        doc = fitz.open(file_path)
        text = ""
        for page_num in range(len(doc)):
            page = doc.load_page(page_num)
            text += page.get_text()
        doc.close()
        return text
    except ImportError:
        print("PyMuPDF not available, trying alternative method...")
        return None
    except Exception as e:
        print(f"Error reading PDF: {e}")
        return None

if __name__ == "__main__":
    pdf_path = "e:\\组队你组不组\\team-up-do-you-want-to-group1\\mcp测试\\B题.pdf"
    if os.path.exists(pdf_path):
        content = read_pdf(pdf_path)
        if content:
            print(content)
        else:
            print("Failed to read PDF content")
    else:
        print(f"PDF file not found: {pdf_path}")